module AdHelper
  #首页广告
  def get_wap_ads
    @ad = nil
    ads = Ad.find :all,
      :conditions =>['status = ? and orders = ?','1',1],
      :order => 'rand()',
      :limit => '1'
    if ads.size > 0
      @ad = ads[0]
    end
    return @ad
  end

  #栏目广告
  def get_col_ads
    @ad = nil
    ads = Ad.find :all,
      :conditions =>['status = ? and orders = ?','1',2],
      :order => 'rand()',
      :limit => '1'
    if ads.size > 0
      @ad = ads[0]
    end
    return @ad
  end

  #资源广告
  def get_res_ads   
    @ads = Ad.find :all,
      :conditions =>['status = ? and orders = ?','1',3],
      :order => 'rand()',
      :limit => '3'    
    return @ads
  end

  #固定广告
  def get_gd_ads
    @ads = Ad.find :all,
      :conditions =>['status = ? and orders = ?','1',4],
      :order => 'rand()',
      :limit => '4'
    return @ads
  end
end
